<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>Mobile Phone Store - Shopping Cart</title>
    <link rel="stylesheet" href="../css/shopcart.css">
</head>
<body>
<div id="header">
    <h1>${SESSION_USERNAME}的购物车</h1>
    <nav>
        <ul>
            <li><a href="${pageContext.request.contextPath}/findAll">去商城</a></li>
        </ul>
    </nav>
</div>
<div id="content">
    <table>
        <thead>
        <tr>
            <th>图片</th>
            <th>名称</th>
            <th>单价</th>
            <th>数量</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${list}" var="li">
            <tr>
                <td><img src="${li.image}"></td>
                <td>${li.name}</td>
                <td>${li.price}</td>
                <td>
                    <button class="btnn" type="submit" value="${li.bookId}" onclick="jian('${li.bookId}')">-1</button>
                        ${li.number}
                    <button class="btnn" type="submit" value="${li.bookId}" onclick="jia('${li.bookId}')">+1</button>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <hr>
    <div class="address">
        <form action="${pageContext.request.contextPath}/user/setAddress">
            地址:<input type="text" name="address" value="${add.detail}">
            <br>
            电话:<input type="text" name="phone" value="${add.phone}">
            <br>
            <button type="submit">确定</button>
        </form>
    </div>
    <div id="total">
        总计:${totalAmount}
    </div>
    <button id="ok" onclick="nomoney()">结算</button>
</div>

<script>
    function jian(id){
        window.location.href="${pageContext.request.contextPath}/user/less1?iid="+id;
    }
    function jia(id){
        window.location.href="${pageContext.request.contextPath}/user/add1?iid="+id;
    }
    function nomoney(){
        if (window.confirm("确定支付并且生成订单吗？")){
            window.location.href='${pageContext.request.contextPath}/createOrder';
        }
    }

</script>

</body>
</html>